package me.wangqu.weiyouqu.web.rest.business.service;

import me.wangqu.weiyouqu.web.rest.business.dao.SignDao;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.slf4j.Logger;

import java.math.BigDecimal;

/**
 * Created by joln on 2016/6/24.
 */
@Service
public class SignService {
    private final Logger log = LoggerFactory.getLogger(SignService.class);
    @Autowired
    private SignDao signDao;

    /**
     * 判断今天是否能签到
     *
     * @param login
     * @return
     */
    public boolean isSign(final String login) {
        try {
            return signDao.isSignEnable(login);
        } catch (Exception e) {
            log.error("判断签到失败", e.getMessage());
        }

        return false;
    }

    /**
     * 签到
     * @param login
     * @param amount
     * @param ip
     * @return
     */
    public boolean sign(final String login, BigDecimal amount, String ip) {
        try {
            return signDao.sign(login, amount, ip);
        } catch (Exception e) {
            log.error("签到失败", e.getMessage());

        }
        return false;
    }
}
